<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>项目管理组</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>项目基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="name" placeholder="请输入" readonly autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>管理组信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目负责人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=man_xiang&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="man_xiang"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=man_xiang&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="man_xiang_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目专管员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=man_zhuan&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="man_zhuan"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=man_zhuan&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="man_zhuan_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">资料专员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=man_zi&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="man_zi"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=man_zi&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">成本专员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=man_cheng&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="man_cheng"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=man_cheng&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">质安专员</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=man_zhian&type=user&single=2', '770px', '490px');"></div>
                                <div class="tanxiannei" id="man_zhian"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=man_zhian&type=user&single=2', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>

        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_engin_manage,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                $("#name").val(data.name);


                if(data.man_xiang_info.length > 0){
                    tan_tags_init('#man_xiang', data.man_xiang_info);
                }
                if(data.man_zhuan_info.length > 0){
                    tan_tags_init('#man_zhuan', data.man_zhuan_info);
                }
                if(data.man_zi_info.length > 0){
                    tan_tags_init('#man_zi', data.man_zi_info);
                }
                if(data.man_cheng_info.length > 0){
                    tan_tags_init('#man_cheng', data.man_cheng_info);
                }
                if(data.man_zhian_info.length > 0){
                    tan_tags_init('#man_zhian', data.man_zhian_info);
                }

                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('submit(add)', function(data){
            data.field.man_xiang = tan_tags_getvalue("#man_xiang", 'user');
            data.field.man_zhuan = tan_tags_getvalue("#man_zhuan", 'user');
            data.field.man_zi = tan_tags_getvalue("#man_zi", 'user');
            data.field.man_cheng = tan_tags_getvalue("#man_cheng", 'user');
            data.field.man_zhian = tan_tags_getvalue("#man_zhian", 'user');

            var validRes = true;
            if(!data.field.man_xiang){
                $("#man_xiang").parents('.tanxian').addClass('tanerror');
                $('#man_xiang_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#man_xiang").parents('.tanxian').removeClass('tanerror');
                $('#man_xiang_tanerror').text('');
            }
            if(!data.field.man_zhuan){
                $("#man_zhuan").parents('.tanxian').addClass('tanerror');
                $('#man_zhuan_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#man_zhuan").parents('.tanxian').removeClass('tanerror');
                $('#man_zhuan_tanerror').text('');
            }
            if(!validRes){return false;}

            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_engin_manage, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
